/**
 备件管理接口
 **/
import { http } from "@/utils/http";

type ResultTable = {
  total?: number;
  data?: Array<any>;
};
// 入库table接口返回值
type ResultWarehousingTable = {
  id: String;
  inNum: String;
  inboundName: String;
  inDate: String;
  factoryArea: String;
  factoryAreaDesc: String;
  className: String;
  classNameDesc: String;
  systemVal: String;
  systemValDesc: String;
  source: String;
  sourceDesc: String;
  billNum: String;
  remark: String;
  inventoryDetailDTOList: Array<any>;
};
// 台账table接口返回值
type ResultLedgerTable = {
  id: String;
  sparePartCode: String;
  sparePartName: String;
  specificationCode: String;
  brandVal: String;
  brandValDesc: String;
  factoryArea: String;
  factoryAreaDesc: String;
  className: String;
  classNameDesc: String;
  systemVal: String;
  systemValDesc: String;
  mapNum: String;
  sparePartLevel: String;
  sparePartLevelDesc: String;
  sparePartUnit: String;
  sparePartUnitDesc: String;
  warehousePosition: String;
  warehousePositionDesc: String;
  principalId: String;
  principalName: String;
  principalPhone: String;
  usedLife: String;
  sparePartLifeUnit: String;
  remark: String;
  alarmStock: String;
  shouldStock: String;
  maxStock: String;
  class: String;
  type: String;
  categoryDesc: String;
  model: String;
  supplyModel: String;
  pictureList: Array<any>;
  fileList: Array<any>;
  category: String;
  typeCode: String;
  brandCode: String;
  modelCode: String;
  usedLifeUnit: String;
};
// 出库table接口返回值
type ResultOutboundTable = {
  id: String;
  outNum: String;
  recipientId: String;
  recipientName: String;
  equipmentId: String;
  equipmentName: String;
  used: String;
  usedDesc: String;
  factoryArea: String;
  factoryAreaDesc: String;
  className: String;
  classNameDesc: String;
  systemVal: String;
  systemValDesc: String;
  billNum: String;
  outDate: String;
  remark: String;
  inventoryDetailDTOList: Array<any>;
};
// 盘点table接口返回值
type ResultTakeStockTable = {
  id: String;
  takeStockName: String;
  takeStockCode: String;
  factoryArea: String;
  factoryAreaDesc: String;
  classNameDesc: String;
  systemValDesc: String;
  className: String;
  systemVal: String;
  warehousePosition: String;
  warehousePositionDesc: String;
  planDate: String;
  planStartDate: String;
  planEndDate: String;
  executeStatus: Number;
  executeStatusDesc: String;
  takeStockPeople: String;
  takeStockPeopleName: String;
  remark: String;
  takeStockScope: String;
  inventoryDetailDTOList: Array<any>;
  isDraft: Boolean;
};

// 通用-备件基础数据-查询列表下拉框接口
export const getSparePartsSelect = (data?: object) => {
  return http.request<Array<any>>("post", "/digitaltwins/api/v1/specification/queryList", {
    data
  });
};
/**
 备件管理-备件基础数据接口
 **/
// 查询备件基础数据接口
export const querySparePartsBaseData = (data?: object) => {
  return http.request<ResultTable>("post", "/digitaltwins/api/v1/specification/queryListPage", {
    data
  });
};
// 新增备件基础数据接口
export const addSparePartsBaseData = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/specification/saveSpecification", {
    data
  });
};
// 编辑备件基础数据接口
export const editSparePartsBaseData = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/specification/updateSpecification", {
    data
  });
};
// 删除备件基础数据接口
export const deleteSparePartsBaseData = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/specification/delSpecification", {
    data
  });
};

/**
 备件管理-备件入库接口
 **/
// 查询备件入库接口
export const querySparePartsWarehousing = (data?: object) => {
  return http.request<ResultTable>("post", "/digitaltwins/api/v1/inventoryIn/queryListPage", {
    data
  });
};
// 查询备件入库编号接口
export const querySparePartsWarehousingNum = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/inventoryIn/getInventoryInCode", {
    data
  });
};
// 获取备件入库详情接口
export const getSparePartsWarehousing = (data?: object) => {
  return http.request<ResultWarehousingTable>("post", "/digitaltwins/api/v1/inventoryIn/getInventoryIn", {
    data
  });
};
// 新增备件入库接口
export const addSparePartsWarehousing = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/inventoryIn/saveInventoryIn", {
    data
  });
};
// 编辑备件入库接口
export const editSparePartsWarehousing = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/inventoryIn/updateInventoryIn", {
    data
  });
};
// 删除备件入库接口
export const deleteSparePartsWarehousing = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/inventoryIn/delInventoryIn", {
    data
  });
};
// 查询备件信息选择接口
export const querySparePartsWarehousingInfo = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/sparePartNew/queryChooseList", {
    data
  });
};

/**
 备件管理-台账接口
 **/
// 查询备件台账接口
export const querySparePartsLedger = (data?: object) => {
  return http.request<ResultTable>("post", "/digitaltwins/api/v1/sparePart/queryListPage", {
    data
  });
};
// 获取备件台账详情接口
export const getSparePartsLedger = (data?: object) => {
  return http.request<ResultLedgerTable>("post", "/digitaltwins/api/v1/sparePart/getSparePart", {
    data
  });
};
// 新增备件台账接口
export const addSparePartsLedger = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/sparePart/saveSparePart", {
    data
  });
};
// 编辑备件台账接口
export const editSparePartsLedger = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/sparePart/updateSparePart", {
    data
  });
};
// 删除备件台账接口
export const deleteSparePartsLedger = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/sparePart/delSparePart", {
    data
  });
};
// 查询备件信息选择接口
export const querySparePartsLedgerInfo = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/specification/queryListPage", {
    data
  });
};
// 备件台账-查询备件入库接口
export const queryWarehousingLedger = (data?: object) => {
  return http.request<ResultTable>("post", "/digitaltwins/api/v1/inventoryIn/queryList", {
    data
  });
};
// 备件台账-查询备件出库接口
export const queryOutboundLedger = (data?: object) => {
  return http.request<ResultTable>("post", "/digitaltwins/api/v1/inventoryOut/queryList", {
    data
  });
};
// 备件台账-获取上传图片moduleName
export const getModuleName = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/sparePart/getFileModelName", {
    data
  });
};

/**
 备件管理-出库接口
 **/
// 查询备件出库接口
export const querySparePartsOutbound = (data?: object) => {
  return http.request<ResultTable>("post", "/digitaltwins/api/v1/inventoryOut/queryListPage", {
    data
  });
};
// 查询备件出库编号接口
export const querySparePartsOutboundNum = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/inventoryOut/getInventoryOutCode", {
    data
  });
};
// 获取备件出库详情接口
export const getSparePartsOutbound = (data?: object) => {
  return http.request<ResultOutboundTable>("post", "/digitaltwins/api/v1/inventoryOut/getInventoryOut", {
    data
  });
};
// 新增备件出库接口
export const addSparePartsOutbound = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/inventoryOut/saveInventoryOut", {
    data
  });
};
// 编辑备件出库接口
export const editSparePartsOutbound = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/inventoryOut/updateInventoryOut", {
    data
  });
};
// 删除备件出库接口
export const deleteSparePartsOutbound = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/inventoryOut/delInventoryOut", {
    data
  });
};
// 出库退库接口
export const outSparePartsOutbound = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/inventoryOut/returnInventoryOut", {
    data
  });
};

/**
 备件管理-盘点接口
 **/
// 查询备件盘点接口
export const querySparePartsTakeStock = (data?: object) => {
  return http.request<ResultTable>("post", "/digitaltwins/api/v1/takeStock/queryListPage", {
    data
  });
};
// 获取备件盘点详情接口
export const getSparePartsTakeStock = (data?: object) => {
  return http.request<ResultTakeStockTable>("post", "/digitaltwins/api/v1/takeStock/getTakeStock", {
    data
  });
};
// 新增备件盘点接口
export const addSparePartsTakeStock = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/takeStock/saveTakeStock", {
    data
  });
};
// 编辑备件盘点接口
export const editSparePartsTakeStock = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/takeStock/updateTakeStock", {
    data
  });
};
// 删除备件盘点接口
export const deleteSparePartsTakeStock = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/takeStock/delTakeStock", {
    data
  });
};
// 开始盘点
export const startTakeStock = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/takeStock/startTakeStock", {
    data
  });
};
// 保存盘点数量
export const saveTakeStockQuantity = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/takeStock/takeStockQuantity", {
    data
  });
};
// 获取盘点编码
export const getTakeStockCode = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/takeStock/getTakeStockCode", {
    data
  });
};
// 获取备件统计
export const sparePartCountReport = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/sparePart/sparePartCountReport", {
    data
  });
};
// 参数接口
export interface QueryListPage_6Params {
  /* */
  factoryId?: string;

  /* */
  pageNum?: number;

  /* */
  pageSize?: number;

  /* */
  orderByColumn?: string;

  /* */
  isAsc?: string;

  /*备件名称/编码 */
  brandName?: string;

  /* */
  orderBy?: string;
}

// 响应接口
export interface QueryListPage_6Res {
  /* */
  pageNum: number;

  /* */
  pageSize: number;

  /* */
  total: number;

  /* */
  pages: number;

  /* */
  data: {
    /*品牌id */
    id: number;

    /*品牌名称 */
    name: string;

    /*创建人ID */
    createBy: number;

    /*创建人姓名 */
    createName: string;

    /*创建时间 */
    createTime: Record<string, unknown>;
  }[];
}

/**
 * 备件品牌-查询分页列表
 * @param {object} params 备件品牌分页查询
 * @param {string} params.factoryId
 * @param {number} params.pageNum
 * @param {number} params.pageSize
 * @param {string} params.orderByColumn
 * @param {string} params.isAsc
 * @param {string} params.brandName 备件名称/编码
 * @param {string} params.orderBy
 * @returns
 */
export function queryListPage_6(data: QueryListPage_6Params): Promise<QueryListPage_6Res> {
  return http.post(`/digitaltwins/api/v1/sparePartBrand/queryListPage`, { data });
}

/**
 * 备件品牌-删除-禁用
 * @param {string} id
 * @returns
 */
export function delSparePartBrand(id: number) {
  return http.post(`/digitaltwins/api/v1/sparePartBrand/delSparePartBrand/${id}`);
}
// 参数接口
export interface DelSparePartBrandTypeParams {
  /*类型编码 */
  typeCode: string;

  /*品牌 */
  brandCode: string;
}

/**
 * 备件品牌-删除关联关系
 * @param {object} params 保存备件品牌类型
 * @param {string} params.typeCode 类型编码
 * @param {string} params.brandCode 品牌
 * @returns
 */
export function delSparePartBrandType(data: DelSparePartBrandTypeParams) {
  return http.post(`/digitaltwins/api/v1/sparePartBrand/delSparePartBrandType`, { data });
}
// 响应接口
export interface QueryListByTypeCodeRes {
  /*品牌id */
  id: number;

  /*品牌名称 */
  name: string;

  /*创建人ID */
  createBy: number;

  /*创建人姓名 */
  createName: string;

  /*创建时间 */
  createTime: Record<string, unknown>;
}

/**
 * 备件类型-根据类型code查询品牌
 * @param {string} typeCode
 * @returns
 */
export function queryListByTypeCode(typeCode: string): Promise<QueryListByTypeCodeRes[]> {
  return http.post(`/digitaltwins/api/v1/sparePartBrand/queryListByTypeCode/${typeCode}`);
}
// 参数接口
export interface SaveSparePartBrandParams {
  /*品牌id */
  id?: number;

  /*品牌名称 */
  name: string;
}

/**
 * 备件品牌-新增数据
 * @param {object} params 保存备件品牌
 * @param {number} params.id 品牌id
 * @param {string} params.name 品牌名称
 * @returns
 */
export function saveSparePartBrand(data: SaveSparePartBrandParams) {
  return http.post(`/digitaltwins/api/v1/sparePartBrand/saveSparePartBrand`, { data });
}
// 参数接口
export interface SaveSparePartBrandTypeParams {
  /*类型编码 */
  typeCode: string;

  /*品牌 */
  brandCode: string;
}
/**
 * 备件品牌-关联类型
 * @param {object} params 保存备件品牌类型
 * @param {string} params.typeCode 类型编码
 * @param {string} params.brandCode 品牌
 * @returns
 */
export function saveSparePartBrandType(data: SaveSparePartBrandTypeParams) {
  return http.post(`/digitaltwins/api/v1/sparePartBrand/saveSparePartBrandType`, { data });
}
// 参数接口
export interface UpdateSparePartBrandParams {
  /*品牌id */
  id?: number;

  /*品牌名称 */
  name: string;
}

/**
 * 备件品牌-修改数据
 * @param {object} params 保存备件品牌
 * @param {number} params.id 品牌id
 * @param {string} params.name 品牌名称
 * @returns
 */
export function updateSparePartBrand(data: UpdateSparePartBrandParams) {
  return http.post(`/digitaltwins/api/v1/sparePartBrand/updateSparePartBrand`, { data });
}

/**
 * 备件型号-删除-禁用
 * @param {string} id
 * @returns
 */
export function delSparePartModel(id: number) {
  return http.post(`/digitaltwins/api/v1/sparePartModel/delSparePartModel/${id}`);
}
// 参数接口
export interface QueryListPage_5Params {
  /* */
  factoryId?: string;

  /* */
  pageNum?: number;

  /* */
  pageSize?: number;

  /* */
  orderByColumn?: string;

  /* */
  isAsc?: string;

  /*厂内型号 */
  model?: string;

  /*厂商型号 */
  supplyModel?: string;

  /*品牌编码 */
  brandCode?: string;

  /*类型编码 */
  typeCode?: string;

  /*种类 */
  category?: string;

  /* */
  orderBy?: string;
}

// 响应接口
export interface QueryListPage_5Res {
  /* */
  pageNum: number;

  /* */
  pageSize: number;

  /* */
  total: number;

  /* */
  pages: number;

  /* */
  data: {
    /*型号id */
    id: number;

    /*型号编码 */
    code: string;

    /*厂内型号 */
    model: string;

    /*厂商型号 */
    supplyModel: string;

    /*品牌编码 */
    brandCode: string;

    /*品牌名称 */
    brandName: string;

    /*类型编码 */
    typeCode: string;

    /*类型名称 */
    typeName: string;

    /*种类 */
    category: string;

    /*种类描述 */
    categoryDesc: string;

    /*创建人ID */
    createBy: number;

    /*创建人姓名 */
    createName: string;

    /*创建时间 */
    createTime: Record<string, unknown>;
  }[];
}

/**
 * 备件型号-查询分页列表
 * @param {object} params 备件型号分页查询
 * @param {string} params.factoryId
 * @param {number} params.pageNum
 * @param {number} params.pageSize
 * @param {string} params.orderByColumn
 * @param {string} params.isAsc
 * @param {string} params.model 厂内型号
 * @param {string} params.supplyModel 厂商型号
 * @param {string} params.brandCode 品牌编码
 * @param {string} params.typeCode 类型编码
 * @param {string} params.category 种类
 * @param {string} params.orderBy
 * @returns
 */
export function queryListPage_5(data: QueryListPage_5Params): Promise<QueryListPage_5Res> {
  return http.post(`/digitaltwins/api/v1/sparePartModel/queryListPage`, { data });
}
// 参数接口
export interface SaveSparePartModelParams {
  /*型号id */
  id?: number;

  /*厂内型号 */
  model: string;

  /*厂商型号 */
  supplyModel: string;

  /*品牌编码 */
  brandCode: string;

  /*类型编码 */
  typeCode: string;

  /*种类 */
  category: string;
}

/**
 * 备件型号-新增数据
 * @param {object} params 保存备件型号
 * @param {number} params.id 型号id
 * @param {string} params.model 厂内型号
 * @param {string} params.supplyModel 厂商型号
 * @param {string} params.brandCode 品牌编码
 * @param {string} params.typeCode 类型编码
 * @param {string} params.category 种类
 * @returns
 */
export function saveSparePartModel(data: SaveSparePartModelParams) {
  return http.post(`/digitaltwins/api/v1/sparePartModel/saveSparePartModel`, { data });
}
// 参数接口
export interface UpdateSparePartModelParams {
  /*型号id */
  id?: number;

  /*厂内型号 */
  model: string;

  /*厂商型号 */
  supplyModel: string;

  /*品牌编码 */
  brandCode: string;

  /*类型编码 */
  typeCode: string;

  /*种类 */
  category: string;
}

/**
 * 备件型号-修改数据
 * @param {object} params 保存备件型号
 * @param {number} params.id 型号id
 * @param {string} params.model 厂内型号
 * @param {string} params.supplyModel 厂商型号
 * @param {string} params.brandCode 品牌编码
 * @param {string} params.typeCode 类型编码
 * @param {string} params.category 种类
 * @returns
 */
export function updateSparePartModel(data: UpdateSparePartModelParams) {
  return http.post(`/digitaltwins/api/v1/sparePartModel/updateSparePartModel`, { data });
}

/**
 * 备件类型-删除-禁用
 * @param {string} id
 * @returns
 */
export function delSparePartType(id: number) {
  return http.post(`/digitaltwins/api/v1/sparePartType/delSparePartType/${id}`);
}
// 响应接口
export interface GetSparePartTypeRes {
  /*备件类型id */
  id: number;

  /*上级备件类型id */
  parentId: number;

  /*类型名称 */
  name: string;

  /*类型编码 */
  code: string;

  /*路径 */
  path: string;

  /*种类 */
  category: string;

  /*种类描述 */
  categoryDesc: string;

  /*课室 */
  className: string;

  /*课室描述 */
  classNameDesc: string;

  /*排序 */
  sort: number;

  /*创建人姓名 */
  createName: string;

  /*创建时间 */
  createTime: Record<string, unknown>;
}

/**
 * 备件类型-查询详情数据
 * @param {string} id
 * @returns
 */
export function getSparePartType(id: number): Promise<GetSparePartTypeRes> {
  return http.post(`/digitaltwins/api/v1/sparePartType/getSparePartType/${id}`);
}
// 响应接口
export interface QueryListByBrandCodeRes {
  /*备件类型id */
  id: number;

  /*上级备件类型id */
  parentId: number;

  /*类型名称 */
  name: string;

  /*类型编码 */
  code: string;

  /*路径 */
  path: string;

  /*种类 */
  category: string;

  /*种类描述 */
  categoryDesc: string;

  /*课室 */
  className: string;

  /*课室描述 */
  classNameDesc: string;

  /*排序 */
  sort: number;

  /*创建人姓名 */
  createName: string;

  /*创建时间 */
  createTime: Record<string, unknown>;
}

/**
 * 备件类型-根据品牌code查询类型
 * @param {string} brandCode
 * @returns
 */
export function queryListByBrandCode(brandCode: string): Promise<QueryListByBrandCodeRes[]> {
  return http.post(`/digitaltwins/api/v1/sparePartType/queryListByBrandCode/${brandCode}`);
}

/**
 * 备件类型-列表数据-tree
 * @param {object} params 备件类型
 * @param {string} params.factoryId
 * @param {string} params.className 课室
 * @param {string} params.category 种类
 * @returns
 */
export function queryListTree_1(data) {
  return http.post(`/digitaltwins/api/v1/sparePartType/queryListTree`, { data });
}
// 参数接口
export interface SaveSparePartTypeParams {
  /*备件类型id */
  id?: number;

  /*上级备件类型id */
  parentId?: number;

  /*类型名称 */
  name: string;

  /*种类 */
  category: string;

  /*课室 */
  className: string;

  /*排序 */
  sort?: number;
}
/**
 * 备件类型-新增数据
 * @param {object} params 保存备件类型
 * @param {number} params.id 备件类型id
 * @param {number} params.parentId 上级备件类型id
 * @param {string} params.name 类型名称
 * @param {string} params.category 种类
 * @param {string} params.className 课室
 * @param {number} params.sort 排序
 * @returns
 */
export function saveSparePartType(data: SaveSparePartTypeParams) {
  return http.post(`/digitaltwins/api/v1/sparePartType/saveSparePartType`, { data });
}
// 参数接口
export interface UpdateSparePartTypeParams {
  /*备件类型id */
  id?: number;

  /*上级备件类型id */
  parentId?: number;

  /*类型名称 */
  name: string;

  /*种类 */
  category: string;

  /*课室 */
  className: string;

  /*排序 */
  sort?: number;
}
/**
 * 备件类型-修改数据
 * @param {object} params 保存备件类型
 * @param {number} params.id 备件类型id
 * @param {number} params.parentId 上级备件类型id
 * @param {string} params.name 类型名称
 * @param {string} params.category 种类
 * @param {string} params.className 课室
 * @param {number} params.sort 排序
 * @returns
 */
export function updateSparePartType(data: UpdateSparePartTypeParams) {
  return http.post(`/digitaltwins/api/v1/sparePartType/updateSparePartType`, { data });
}

/**
 备件管理-台账接口
 **/
// 查询备件台账接口
export const querySparePartsLedgerNew = (data?: object) => {
  return http.request<ResultTable>("post", "/digitaltwins/api/v1/sparePartNew/queryListPage", {
    data
  });
};
// 获取备件台账详情接口
export const getSparePartsLedgerNew = (data?: object) => {
  return http.request<ResultLedgerTable>("post", "/digitaltwins/api/v1/sparePartNew/getSparePart", {
    data
  });
};
// 新增备件台账接口
export const addSparePartsLedgerNew = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/sparePartNew/saveSparePart", {
    data
  });
};
// 编辑备件台账接口
export const editSparePartsLedgerNew = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/sparePartNew/updateSparePart", {
    data
  });
};
// 删除备件台账接口
export const deleteSparePartsLedgerNew = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/sparePartNew/delSparePart", {
    data
  });
};
// 备件台账-获取上传图片moduleName
export const getModuleNameNew = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/sparePartNew/getFileModelName", {
    data
  });
};
// 备件台账-查询出入库记录
export const queryInOutRecordPage = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/sparePartNew/queryInOutRecordPage", {
    data
  });
};
// 备件台账-查询关联设备
export const queryListBySpareModel = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/equipment/queryListBySpareModel", {
    data
  });
};
// 备件统计-获取备件统计
export const sparePartCountReportNew  = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/sparePartNew/sparePartCountReport", {
    data
  });
};
// 备件品牌-查询列表
export const queryBrandList = (data?: object) =>  {
  return http.request("post", "/digitaltwins/api/v1/sparePartBrand/queryList", {
    data
  });
};
